﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Howork.Scripts
{
    public partial class DeviceHistory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public void du_Download()
        {
            DeviceManage dm = new DeviceManage();
            string begin = Request["begin_time"];
            string end = Request["end_time"];
            int type_id = Convert.ToInt32(Request["type_id"]);
            DateTime du_begin = DateTime.Parse(begin);
            DateTime du_end = DateTime.Parse(end);
            List<DeviceUsage> du = dm.GetDeviceUsageHistory(du_begin, du_end, type_id);

            String fileName = FileAdapter.getCSV(du, "设备使用记录.csv");
            Page.Response.Clear();
            bool success = FileAdapter.provideCSVDownload(Page.Request, Page.Response, fileName, 1024000);
            if (!success)
                Response.Write("下载文件出错！");
            Page.Response.End();
        }
    }
}